package com.jt.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jt.pojo.Shopping;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface ShoppingMapper extends BaseMapper<Shopping> {
    @Update("UPDATE shopping SET nummer=nummer+#{num} WHERE id=#{id}")
    void updateShopping(Integer num, Integer id);

    @Select("select sum(nummer) from shopping where parent_id=#{id}")
    int iNum(Integer id);

    @Delete("delete from shopping where parent_id=#{id}")
    void deleteShopping(Integer id);


    @Update("update shopping set nummer=nummer-1 where id=#{id}")
    void decreasenummer(Integer id);

    @Update("UPDATE shopping SET nummer=nummer+1 WHERE id=#{id};")
    void addnummer(Integer id);

    @Delete("delete from shopping where id=#{id} ")
    void deletenummer(Integer id);

    @Delete("delete from shopping where parent_id=#{id}")
    void deleteAllCart(Integer id);
}
